home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / test / suplib / strnicmp.c < prev   
C/C++ Source or Header  |  1992-10-25  |  495b  |  39 lines

  1.  
  2. /*
  3.  *  STRNICMP.C
  4.  *
  5.  *  (C)Copyright 1990, Matthew Dillon, All Rights Reserved
  6.  */
  7.  
  8. #include <string.h>
  9. #include <ctype.h>
  10.  
  11. #ifndef HYPER
  12. #define HYPER(x) x
  13. #endif
  14.  
  15. typedef unsigned char ubyte;
  16.  
  17. int
  18. HYPER(strnicmp)(s, d, n)
  19. const char *s;
  20. const char *d;
  21. int n;
  22. {
  23.     ubyte c;
  24.  
  25.     if (n == 0)
  26.     return(0);
  27.  
  28.     while (tolower(c = *s) == tolower(*(ubyte *)d)) {
  29.     if (c == 0 || --n == 0)
  30.         return(0);
  31.     ++s;
  32.     ++d;
  33.     }
  34.     if (tolower(c) < tolower(*(ubyte *)d))
  35.     return(-1);
  36.     return(1);
  37. }
  38.  
  39.